package gold.digger;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC500 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public String[] findWords(String[] words) {
            List<String> list = new ArrayList<String>();
            String rowIdx = "12210111011122000010020202";
            for (String word : words) {
                boolean isValid = true;
                char idx = rowIdx.charAt(Character.toLowerCase(word.charAt(0)) - 'a');
                for (int i = 1; i < word.length(); ++i) {
                    if (rowIdx.charAt(Character.toLowerCase(word.charAt(i)) - 'a') != idx) {
                        isValid = false;
                        break;
                    }
                }
                if (isValid) {
                    list.add(word);
                }
            }
            String[] ans = new String[list.size()];
            for (int i = 0; i < list.size(); ++i) {
                ans[i] = list.get(i);
            }
            return ans;
        }
    }

    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC500 an = new LC500();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
